/**
 * Created by zycool on 2016/8/31.
 * 登录
 */

;(function ($, window, document, undefined) {

    var $login_form = $('#JQ_login_form');

    // enter
    document.onkeydown = function (event) {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 13) {
            var vary = $login_form.verify();
            if (vary) {
                $login_form.submit();
            }
        }
    };

    // 登录
    $('#JQ_login').click(function () {
        var vary = $login_form.verify();
        if (vary) {
            /*var accout = $('input[name="username"]').val();
            var password = $('input[name="password"]').val();
            DyyBase.ajax(DyyBase.root_path + '/ajaxLogin.json',{userName:accout, pwd:password},function(dataset){
                if(dataset.bool){
                    window.location.href = DyyBase.root_path + '/toHome.jsp';
                }else{
                    $('#JQ_login_message').text(dataset.result);
                }
            });*/
            $login_form.submit();
        }
    });

    // 记住密码
    $('#JQ_mark_pass').click(function () {
        var $this = $(this);
        var $chk = $this.find('i.zy-login-icon-chk');
        $chk.toggleClass('active');
        if($chk.hasClass('active')){
            $('#JQ_rememberMe').val('true');
        }else{
            $('#JQ_rememberMe').val('false');
        }
    });

    // 清空所有缓存
    // 注意只有session
    Dyy.clearStorage();

})($, window, document);
